package com.jf.identity.holder;

import org.springframework.stereotype.Component;

/**
 * @author FCG
 */
@Component
public class DataSourceKeyHolder {
    private volatile ThreadLocal<String> dataSourceKey = new ThreadLocal<>();

    public void setDataSourceKey(String key) {
        dataSourceKey.remove();
        dataSourceKey.set(key);
    }

    public String getDataSourceKey() {
        return dataSourceKey.get();
    }

    public void remove() {
        dataSourceKey.remove();
    }
}
